﻿using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinsionApp.Models.Message;

namespace WinsionApp.Pages
{
   public class SubscriberViewModel : Screen, IHandle<MyEvent>
    {
        private readonly IEventAggregator _eventAggregator;
        public string ReceivedMessage { get; set; }

        public SubscriberViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this); // 订阅事件
        }

        // 实现 IHandle<MyEvent> 接口的方法，处理事件
        public void Handle(MyEvent message)
        {
            ReceivedMessage = message.Message;
        }
    }
}
